home *** CD-ROM | disk | FTP | other *** search
/ Info-Mac 4 / Info_Mac IV CD-ROM (Pacific HiTech Inc.)(August 1994).iso / Development / Source / MSG Demo 1.4.source Folder / Demo ƒ / Wipes ƒ / Split scroll U-D.c < prev    next >
Text File  |  1994-04-15  |  3KB  |  104 lines

  1. /**********************************************************************\
  2.  
  3. File:        Split scroll U-D.c
  4.  
  5. Purpose:    Graphic effect from offscreen bitmap to main window (on
  6.             screen).  See comments below for more description.
  7.  
  8. This program is free software; you can redistribute it and/or modify
  9. it under the terms of the GNU General Public License as published by
  10. the Free Software Foundation; either version 2 of the License, or
  11. (at your option) any later version.
  12.  
  13. This program is distributed in the hope that it will be useful,
  14. but WITHOUT ANY WARRANTY; without even the implied warranty of
  15. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  16. GNU General Public License for more details.
  17.  
  18. You should have received a copy of the GNU General Public License
  19. along with this program in a file named "GNU General Public License".
  20. If not, write to the Free Software Foundation, 675 Mass Ave,
  21. Cambridge, MA 02139, USA.
  22.  
  23. \**********************************************************************/
  24.  
  25. #include "timing.h"
  26.  
  27. #define CorrectTime 4
  28. #define theWindowWidth (boundsRect.right-boundsRect.left)
  29. #define theWindowHeight (boundsRect.bottom-boundsRect.top)
  30.  
  31. pascal short SplitScrollUD(GrafPtr sourceGrafPtr, GrafPtr destGrafPtr, Rect boundsRect);
  32.  
  33. /* Draw a line from the topleft to the bottomright of the screen and split the
  34.    screen into two regions.  The top region scrolls down and the bottom region
  35.    scrolls up. */
  36.    
  37. pascal short SplitScrollUD(GrafPtr sourceGrafPtr, GrafPtr destGrafPtr, Rect boundsRect)
  38. {
  39.     int            x;
  40.     Rect        theTopRect, topdest, theBottomRect, bottomdest;
  41.     Rect        topscrollsource, topscrolldest, bottomscrollsource, bottomscrolldest;
  42.     RgnHandle    toprgn,bottomrgn;
  43.     int            BoxSize;
  44.     
  45.     BoxSize=theWindowHeight/25;
  46.     toprgn=NewRgn();
  47.     SetEmptyRgn(toprgn);
  48.     MoveTo(0,0);
  49.     OpenRgn();
  50.         Line(theWindowWidth,0);
  51.         Line(0,theWindowHeight);
  52.         LineTo(0,0);
  53.     CloseRgn(toprgn);
  54.     OffsetRgn(toprgn, boundsRect.left, boundsRect.top);
  55.     
  56.     bottomrgn=NewRgn();
  57.     SetEmptyRgn(bottomrgn);
  58.     MoveTo(0,0);
  59.     OpenRgn();
  60.         Line(0,theWindowHeight);
  61.         Line(theWindowWidth,0);
  62.         LineTo(0,0);
  63.     CloseRgn(bottomrgn);
  64.     OffsetRgn(bottomrgn, boundsRect.left, boundsRect.top);
  65.     
  66.     topscrollsource=boundsRect;
  67.     topscrollsource.bottom-=BoxSize;
  68.     topscrolldest = topscrollsource;
  69.     OffsetRect(&topscrolldest, 0, BoxSize);
  70.     topdest = boundsRect;
  71.     topdest.bottom=topdest.top+BoxSize;
  72.     SetRect(&theTopRect, boundsRect.left, boundsRect.bottom-BoxSize, boundsRect.right, boundsRect.bottom);
  73.     
  74.     bottomscrollsource=boundsRect;
  75.     bottomscrollsource.top+=BoxSize;
  76.     bottomscrolldest=bottomscrollsource;
  77.     OffsetRect(&bottomscrolldest, 0, -BoxSize);
  78.     bottomdest=boundsRect;
  79.     bottomdest.top=bottomdest.bottom-BoxSize;
  80.     SetRect(&theBottomRect, boundsRect.left, boundsRect.top, boundsRect.right, boundsRect.top+BoxSize);
  81.     
  82.     for(x = theWindowHeight - BoxSize; x >= 0; x -= BoxSize)
  83.     {
  84.         StartTiming();
  85.         CopyBits(&(destGrafPtr->portBits), &(destGrafPtr->portBits),
  86.                 &topscrollsource, &topscrolldest, 0, toprgn);
  87.         CopyBits(&(sourceGrafPtr->portBits), &(destGrafPtr->portBits),
  88.                 &theTopRect, &topdest, 0, toprgn);
  89.         theTopRect.bottom-=BoxSize;
  90.         theTopRect.top-=BoxSize;
  91.         
  92.         CopyBits(&(destGrafPtr->portBits), &(destGrafPtr->portBits),
  93.                 &bottomscrollsource, &bottomscrolldest, 0, bottomrgn);
  94.         CopyBits(&(sourceGrafPtr->portBits), &(destGrafPtr->portBits),
  95.                 &theBottomRect, &bottomdest, 0, bottomrgn);
  96.         theBottomRect.top+=BoxSize;
  97.         theBottomRect.bottom+=BoxSize;
  98.         
  99.         TimeCorrection(CorrectTime);
  100.     }
  101.     
  102.     return 0;
  103. }
  104.